package com.zlq.controller;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class Task {
    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
    //每三秒执行一次
    @Scheduled(fixedRate = 3000)
    private void can(){
        System.out.println("李云鹏啊"+dateFormat.format(new Date()));
    }

    //每2秒执行一次
    @Scheduled(cron = "0/2 * * * * *")
    private void canLook(){
        System.out.println("李云鹏啊"+dateFormat.format(new Date()));
    }
}
